home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / doc / uwproto.ms < prev    next >
Text File  |  1991-01-25  |  25KB  |  714 lines

  1. .\" This file should be processed by nroff or troff with the -ms macro set
  2. .ds uw "\s-2UW\s0
  3. .de T=
  4. .ie t .ta 8n 28n 36n 44n
  5. .el .ta 8n 24n 32n 40n
  6. ..
  7. .DA September 30, 1986
  8. .TL
  9. UW Protocol
  10. .AU
  11. John D. Bruner
  12. .SH
  13. Introduction
  14. .PP
  15. \*(uw is a multiple-window interface to UNIX.\**
  16. .FS
  17. UNIX is a registered trademark of American Telephone and Telegraph.
  18. .br
  19. Macintosh is a trademark of McIntosh Laboratories,
  20. and is licensed to Apple Computer.
  21. .br
  22. ADM-31 is a trademark of Lear Siegler, Inc.
  23. .br
  24. VT52 is a trademark of Digital Equipment Corporation.
  25. .br
  26. The Tektronix 4010 is a graphics terminal manufactured
  27. by Tektronix, Inc.
  28. .FE
  29. It comprises two parts:
  30. a program which runs on a Macintosh
  31. (referred to hereafter as ``the client'')
  32. and a server program which runs on the UNIX system
  33. (``the host'').
  34. These two programs exchange information by sending
  35. data across a serial communications line.
  36. This information consists of data
  37. and control and status messages relating to its presentation.
  38. The structure of this information is defined by
  39. the \*(uw protocol
  40. and is the subject matter of this document.
  41. .PP
  42. \*(uw version 3 actually defines three protocols.
  43. Internally they are assigned numbered,
  44. while the user interface and documentation refer to them
  45. by name.
  46. The correspondence is as follows:
  47. .IP 0
  48. Protocol 0 is referred to as the ``serverless protocol''
  49. or ``single terminal emulator protocol,''
  50. because its use does not require a server on the host.
  51. .IP 1
  52. Protocol 1 is called the ``original \*(uw protocol,''
  53. because it was the only protocol supported by the first
  54. versions of \*(uw
  55. (versions 1.6 and 2.10).
  56. .IP 2
  57. Protocol 2 is called the ``extended \*(uw protocol,''
  58. or (sometimes)
  59. the ``\*(uw version 3 protocol.''
  60. .SH
  61. Protocol 0 \(em The Serverless Protocol
  62. .PP
  63. Protocol 0 is not really a \*(uw protocol at all.
  64. The client speaks protocol 0 when it is communicating
  65. directly with a host,
  66. rather than communicating through a server program
  67. running on the host.
  68. Protocol 0 is simply 7-bit or 8-bit ASCII.
  69. Every byte transmitted in protocol 0 represents itself,
  70. with the possible exception of the two flow-control characters
  71. XON (control-Q)
  72. and
  73. XOFF (control-S).
  74. Protocol 0 does not specify whether these characters are
  75. to be used for flow-control purposes or for data transmission.
  76. The client program on the Macintosh and the host's terminal driver
  77. can be configured to use or ignore flow-control.
  78. .PP
  79. Protocol 0 does not specify whether data is transmitted
  80. using 8-bit ASCII or 7-bit ASCII.
  81. The user must choose the appropriate transmission format
  82. and is reponsible for configuring both the client and the host
  83. accordingly.
  84. .SH
  85. Protocol 1 \(em The Original \*(uw Protocol
  86. .PP
  87. Protocol 1 was the only protocol which was used in
  88. the first versions of \*(uw
  89. (versions 1.6 and 2.10).
  90. It defines seven ``windows,''
  91. each of which is an independent data stream.
  92. Through the transmission of appropriate commands,
  93. windows may be created or destroyed,
  94. and data may be directed to a particular window.
  95. Data which is transmitted from the client to the host
  96. is referred to as ``input data,''
  97. while data transmitted from the host to the client
  98. is referred to as ``output data.''
  99. In each direction a ``current window'' specifies
  100. the recipient of data bytes.
  101. (For example,
  102. if the client wishes to send data to window 4,
  103. it first sends a ``select window 4 as input window''
  104. command and then sends the data.
  105. Until the client sends another ``select input window'' command,
  106. all further data that it transmits will be received
  107. as data for window 4.)
  108. The current input window and current output window may be different.
  109. .PP
  110. Protocol 1 encodes all information into 7-bit symbols;
  111. it does not depend upon the value of the most-significant bit
  112. (sometimes used for parity purposes).
  113. Commands are encoded into two bytes:
  114. a prefix byte (P1_IAC)
  115. and a command byte.
  116. Bit 7
  117. (the second most-significant bit, octal 0100)
  118. specifies whether the command was sent from the host to the client or
  119. .I "vice versa:"
  120. .DS
  121. .T=
  122. #define    P1_IAC    0001    /* intrepret following byte as a command */
  123. #define    P1_DIR    0100    /* command direction: */
  124. #define    P1_DIR_HTOM    0000    /*    from host to Mac (client) */
  125. #define    P1_DIR_MTOH    0100    /*    from Mac (client) to host */
  126. .DE
  127. The command's function is encoded into the next three bits.
  128. There are only seven commands:
  129. .DS
  130. .T=
  131. #define    P1_FN    0070    /* function code: */
  132. #define    P1_FN_NEWW    0000    /*    create new window */
  133. #define    P1_FN_KILLW    0010    /*    kill (destroy) window */
  134. #define    P1_FN_ISELW    0020    /*    select window for input data */
  135. #define    P1_FN_OSELW    0030    /*    select window for output data */
  136. #define    P1_FN_META    0050    /*    add META to next data character */
  137. #define    P1_FN_CTLCH    0060    /*    send control character as data */
  138. #define    P1_FN_MAINT    0070    /*    perform "maintenance function" */
  139. .DE
  140. (The client does not send the P1_FN_OSELW command;
  141. similarly,
  142. the host does not send the P1_FN_ISELW command.)
  143. .PP
  144. The least-significant three bits of the command byte
  145. specify an argument to the function.
  146. For the ``new window'' (P1_FN_NEWW),
  147. ``kill window'' (P1_FN_KILLW),
  148. ``select input'' (P1_FN_ISELW),
  149. and
  150. ``select output'' (P1_FN_OSELW)
  151. commands,
  152. the low three bits specify a window number.
  153. Window number zero is not used.
  154. .PP
  155. There are no arguments to the P1_FN_META command.
  156. It directs that the next data byte to be transmitted
  157. be considered a ``meta'' character;
  158. .I i.e.
  159. a byte with the most-significant bit
  160. (octal 0200)
  161. set.
  162. .PP
  163. The P1_FN_CTLCH command is used to encode three
  164. data characters which cannot be transmitted directly as data.
  165. These are P1_IAC
  166. (which,
  167. if encountered in a transmission,
  168. indicates the start of a two-character command),
  169. and the flow-control characters XON (021)
  170. and XOFF (023).
  171. The low-order three bits of the command byte specify the character:
  172. .DS
  173. .T=
  174. #define    P1_CC    7    /* control character specifier: */
  175. #define    P1_CC_IAC    1    /*    P1_IAC (001) */
  176. #define    P1_CC_XON    2    /*    XON (021) */
  177. #define    P1_CC_XOFF    3    /*    XOFF (023) */
  178. .DE
  179. A meta-control character is transmitted as a P1_FN_META
  180. command followed by the appropriate P1_FN_CTLCH command.
  181. Thus,
  182. the octal character 0201 would be transmitted from the
  183. host to the client as
  184. a four-byte sequence:
  185. .DS
  186. .T=
  187. 0001    (P1_IAC)
  188. 0050    (P1_DIR_HTOM|P1_FN_META)
  189. 0001    (P1_IAC)
  190. 0061    (P1_DIR_HTOM|P1_FN_CTLCH|P1_CC_IAC)
  191. .DE
  192. Note that since the host does not send P1_FN_OSELW commands
  193. and the client sends commands with the 0100 bit set,
  194. the XON and XOFF control characters will never be sent as command bytes.
  195. .PP
  196. ``Maintenance functions'' are defined for operations
  197. which are performed infrequently.
  198. Protocol 1 defines two maintenance functions:
  199. .DS
  200. .T=
  201. #define    P1_MF    7    /* maintenance functions: */
  202. #define    P1_MF_ENTRY    0    /*    start up */
  203. #define    P1_MF_EXIT    7    /*    exit */
  204. .DE
  205. The server sends the P1_MF_ENTRY command when it starts up.
  206. The client responds to this by killing any windows that it
  207. has created
  208. (silently,
  209. .I i.e.
  210. without sending P1_FN_KILLW messages to the host).
  211. Either the client or the server may send the P1_MF_EXIT command
  212. to terminate the session.
  213. When the server on the host receives P1_MF_EXIT
  214. it terminates;
  215. when the client receives this command it will reset to a
  216. simple known state.
  217. .SH
  218. Protocol 2
  219. .PP
  220. \*(uw version 3 provides a number of capabilities
  221. that earlier versions of \*(uw did not.
  222. Among these is an expansion of the host-client interaction.
  223. In order to accomodate the increased flow of information
  224. it was necessary to extend the \*(uw protocol.
  225. One of the significant extensions in protocol 2
  226. is support for a concept called ``window options.''
  227. Window options are described in more detail in the next section.
  228. .PP
  229. Protocol 2 is very similar to protocol 1.
  230. Like protocol 1,
  231. protocol 2 multiplexes a single communications stream
  232. among a maximum of seven windows.
  233. Command bytes in protocol 2 are encoded in the same
  234. fashion as in protocol 1:
  235. a prefix byte
  236. (P2_IAC)
  237. followed by a command byte.
  238. However,
  239. unlike protocol 1,
  240. some protocol 2 commands require more than one command byte.
  241. .PP
  242. The protocol 2 functions are:
  243. .DS
  244. .T=
  245. #define    P2_FN    0070    /* function code: */
  246. #define    P2_FN_NEWW    0000    /*    create new window */
  247. #define    P2_FN_KILLW    0010    /*    kill (destroy) window */
  248. #define    P2_FN_ISELW    0020    /*    select window for input data */
  249. #define    P2_FN_OSELW    0030    /*    select window for output data */
  250. #define    P2_FN_WOPT    0040    /*    communicate window options */
  251. #define    P2_FN_META    0050    /*    add META to next data character */
  252. #define    P2_FN_CTLCH    0060    /*    send control character as data */
  253. #define    P2_FN_MAINT    0070    /*    perform "maintenance function" */
  254. .DE
  255. The P2_FN_KILLW,
  256. P2_FN_ISELW,
  257. P2_FN_OSELW,
  258. and P2_FN_CTLCH
  259. commands are identical to their counterparts in protocol 1.
  260. .PP
  261. The low-order three bits of the P2_FN_META command
  262. represent a control character.
  263. (The low-order three bits of the P1_FN_META command are ignored.)
  264. The encoding is identical to the encoding
  265. for the P2_FN_CTLCH command:
  266. .DS
  267. .T=
  268. #define    P2_CC    7    /* control character specifier: */
  269. #define    P2_CC_IAC    1    /*    P2_IAC (001) */
  270. #define    P2_CC_XON    2    /*    XON (021) */
  271. #define    P2_CC_XOFF    3    /*    XOFF (023) */
  272. .DE
  273. If the low-order three bits are zero,
  274. then the P2_FN_META command acts like the P1_FN_META command \(em
  275. the META bit is set in the next data byte.
  276. If the low-order three bits are not all zero,
  277. the the P2_FN_META command specifies a META-control character.
  278. Thus, the following are all equivalent:
  279. .DS
  280. P1_IAC\ \ P1_FN_META\ \ P1_IAC\ \ P1_FN_CTLCH|P1_CC_IAC
  281. P2_IAC\ \ P2_FN_META\ \ P2_IAC\ \ P2_FN_CTLCH|P2_CC_IAC
  282. P2_IAC\ \ P2_FN_META|P2_CC_IAC
  283. .DE
  284. .PP
  285. The P2_FN_NEWW command differs from the P1_FN_NEWW command
  286. in that the protocol 2 command includes an extra byte.
  287. The byte following the command byte
  288. specifies the type of the window that is being created.
  289. The numeric value of the window type is
  290. added to the ASCII value for a space (blank);
  291. hence,
  292. the window type is always represented by a printable character.
  293. As an example,
  294. if the host wishes to create window 2
  295. with window type 1 (VT-52),
  296. the command sequence is:
  297. .DS
  298. .T=
  299. 0001    (P2_IAC)
  300. 0002    (P2_DIR_HTOM|P2_FN_NEWW|2)
  301. 0041    (`!')
  302. .DE
  303. .PP
  304. The following maintenance functions (P2_FN_MAINT) are defined:
  305. .DS
  306. .T=
  307. #define    P2_MF    7    /* maintenance functions: */
  308. #define    P2_MF_ENTRY    0    /*    start up */
  309. #define    P2_MF_ASKPCL    2    /*    request protocol negotiation */
  310. #define    P2_MF_CANPCL    3    /*    suggest protocol */
  311. #define    P2_MF_SETPCL    4    /*    set new protocol */
  312. #define    P2_MF_EXIT    7    /*    exit */
  313. .DE
  314. The representations of
  315. P2_MF_ENTRY and P2_MF_EXIT are identical to those in protocol 1.
  316. The definition of the ``entry'' function is extended
  317. slightly in protocol 2.
  318. In protocol 1,
  319. the P1_MF_ENTRY command is only sent by the server when it starts up.
  320. The client recognizes this command and initializes itself.
  321. In protocol 2,
  322. the client is permitted to send the P2_MF_ENTRY command
  323. to the server.
  324. Upon receipt of this command,
  325. the server issues the sequence of P2_FN_NEWW commands
  326. and P2_FN_WOPT commands
  327. (described below)
  328. which will reconstruct all of the existing windows
  329. on the client in their current state.
  330. The client uses this command to ``restart'' itself after a crash
  331. or other interruption on its end of the connection.
  332. The three new maintenance functions are used for protocol negotiation.
  333. Protocol negotiation is described in detail below.
  334. .PP
  335. Protocol 2 defines the new command
  336. P2_FN_WOPT
  337. to transmit window option information
  338. between the client and server.
  339. The P2_FN_WOPT command is followed by a variable-length
  340. string of bytes which encode the window options information.
  341. The next section describes the meaning and encoding of
  342. window option information.
  343. .SH
  344. Window Options
  345. .PP
  346. Window options are window attributes
  347. (the latter is a more meaningful name).
  348. For each window,
  349. a maximum of 31 window options may be defined.
  350. These are divided into two categories:
  351. generic and emulation-specific.
  352. Generic window options are attributes which are common
  353. to all window emulation types.
  354. Emulation-specific options are meaningful only for some
  355. subset of the available emulation types.
  356. The following options are generic:
  357. .DS
  358. .T=
  359. #define    WOG_END    0    /* [used as an endmarker] */
  360. #define    WOG_VIS    1    /* visibility */
  361. #define    WOG_TYPE    2    /* window emulation type */
  362. #define    WOG_POS    3    /* window position on screen */
  363. #define    WOG_TITLE    4    /* window title */
  364. #define    WOG_SIZE    5    /* window size (in pixels) */
  365. #define    WOG_6    6    /* [unassigned, reserved] */
  366. #define    WOG_7    7    /* [unassigned, reserved] */
  367. .DE
  368. Terminal emulations define the following emulation-specific options:
  369. .DS
  370. .T=
  371. #define    WOTTY_SIZE    8    /* (row,col) terminal size */
  372. #define    WOTTY_FONTSZ    9    /* font size index */
  373. #define    WOTTY_MOUSE    10    /* mouse interpretation */
  374. #define    WOTTY_BELL    11    /* audible, visual bell */
  375. #define    WOTTY_CURSOR    12    /* cursor shape */
  376. .DE
  377. Window option values are structured types composed
  378. of the following primitive types:
  379. .DS
  380. fixed-length character vectors
  381. variable-length character strings
  382. specified-width unsigned integer data
  383. .DE
  384. .PP
  385. The host and client may exchange the following commands
  386. regarding window options:
  387. .DS
  388. .T=
  389. #define    WOC_SET    0    /* change value of option */
  390. #define    WOC_INQUIRE    2    /* ask about current option value */
  391. #define    WOC_DO    4    /* do report changes to option */
  392. #define    WOC_DONT    5    /* don't report changes to option */
  393. #define    WOC_WILL    6    /* will report changes to option */
  394. #define    WOC_WONT    7    /* won't report changes to option */
  395. .DE
  396. The ``set'' command is sent by either the client or the host
  397. to specify the current value of a window option.
  398. The ``inquire'' command is sent by either the client or the host
  399. when it wishes to know the current value of an option.
  400. The recipient of an ``inquire'' command responds with a
  401. ``set'' command that specifies the current option value.
  402. .PP
  403. The remaining four window option commands
  404. are used by the host
  405. to set up automatic reporting by the client
  406. when the value of a window option changes.
  407. If the host wishes to be informed
  408. when the value of a window option changes
  409. (\fIe.g.\fP when a window is retitled),
  410. it sends a ``do'' command to the client.
  411. The client responds to the ``do'' command
  412. with a ``will'' command
  413. followed immediately by a ``set'' command
  414. (reporting the current value of the option).
  415. Thereafter,
  416. whenever the value of that option changes
  417. the client will send a ``set'' command with the new value
  418. to the host.
  419. If the host wishes the client to stop sending
  420. these ``set'' commands,
  421. the host sends the client a ``don't'' command.
  422. The client responds with a ``won't'' message.
  423. .PP
  424. The reporting status of generic window options is not affected
  425. if the window emulation types changes;
  426. however,
  427. if the emulation type changes,
  428. then reporting for emulation-specific options is ended.
  429. If the host wishes the client to continue
  430. reporting changes in some emulation-specific window options,
  431. it must send the appropriate ``do'' commands.
  432. .PP
  433. Window option commands are grouped together and transmitted
  434. collectively as part of a P2_FN_WOPT command.
  435. That is,
  436. the P2_IAC and P2_FN_WOPT command are immediately
  437. followed by a variable-length string of bytes
  438. which contain window option commands for one or
  439. more options.
  440. The end of a sequence of window option (sub)commands
  441. is indicated by a command which specifies window option zero
  442. (WOG_END).
  443. .PP
  444. All window option commands begin with a one or two
  445. byte command specifier.
  446. The one-byte form is called the ``short'' form,
  447. while the two-byte form is the ``long'' form:
  448. .DS
  449. .ta 8n 32n 48n
  450. #define    WONUM_MIN    1    /* minimum option number */
  451. #define    WONUM_GENERIC    7    /* maximum generic option number */
  452. #define    WONUM_SHORT    14    /* maximum short option number */
  453. #define    WONUM_MAX    31    /* maximum option number */
  454. #define    WONUM_MASK    (017<<3)    /* mask for extraction */
  455. #define    WONUM_SENCODE(n)    (((n)&017)<<3)    /* short encoding function */
  456. #define    WONUM_SDECODE(b)    (((b)>>3)&017)    /* short decoding function */
  457. #define    WONUM_LPREFIX    (017<<3)    /*long encoding prefix */
  458. #define    WONUM_LENCODE(n)    ((n)+' ')    /* long encoding function */
  459. #define    WONUM_LDECODE(c)    (((c)&0177)-' ')    /* long decoding function */
  460. .DE
  461. Commands
  462. specifing options whose numbers are in the range WONUM_MIN to WONUM_SHORT
  463. may use the short form.
  464. In this case,
  465. the window option number is encoded according to WONUM_SENCODE:
  466. it is shifted left by three bits.
  467. The command byte consists of a bitwise ``or'' of
  468. the window option command
  469. (\fIe.g.\fP WOC_INQUIRE)
  470. and the encoded short option number.
  471. .PP
  472. Commands which specify options whose numbers are greater than WONUM_SHORT
  473. must use the long form.
  474. (The long form may be used for options whose numbers are less than WONUM_SHORT,
  475. but there is no reason to do so.)
  476. In this case,
  477. the first byte contains a bitwise ``or'' of
  478. the window option command
  479. (\fIe.g.\fP WOC_INQUIRE)
  480. and the special prefix WONUM_LPREFIX.
  481. The second byte is encoded by WONUM_LENCODE:
  482. the window option number is added to the ASCII code for a space
  483. (thus this byte is always printable).
  484. .PP
  485. All of the window option commands begin with the
  486. one or two byte option command specifier.
  487. Unlike the other window option commands
  488. (which use no additional bytes),
  489. the WOC_SET command is followed by encoded data
  490. (the value of the option).
  491. Option values are constructed from three primitive
  492. data types
  493. (as noted above).
  494. .IP chars 8n
  495. The simplest type of data is a fixed-length character vector.
  496. This is represented directly.
  497. The vector must consist of printable characters.
  498. [This restriction may be eliminated in the future.
  499. The current implementation is able to process non-printable
  500. characters
  501. (including XON and XOFF)
  502. correctly.]
  503. .IP string
  504. Like character vectors,
  505. strings have a maximum length.
  506. However,
  507. unlike character vectors,
  508. strings may contain non-printing characters.
  509. Also,
  510. while all characters in a character vector are sent,
  511. a string may be shorter than its maximum length.
  512. It is terminated by a null (000) byte.
  513. [Hence,
  514. a string may not contain an embedded null byte.]
  515. .IP udata
  516. The remaining data type is unsigned integer data.
  517. This data has a fixed width measured in bits.
  518. The value is encoded in ``little-endian'' fashion
  519. into the low six bits of successive characters.
  520. The (octal) 0100 bit of each character is set.
  521. The number of characters required to hold an integer
  522. varies from one
  523. (for data which is one to six bits wide)
  524. to six
  525. (for data which is thirty-two bits wide).
  526. .PP
  527. The window options defined above have arguments as follows
  528. (all integers are unsigned):
  529. .IP WOG_VIS 20n
  530. This is a 1-bit integer
  531. which is nonzero iff the window is visible.
  532. .IP WOG_POS
  533. This consists of two 12-bit integers
  534. which respectively specify the vertical and horizontal
  535. offsets of the window on the client's screen.
  536. .IP WOG_TITLE
  537. This is a string of maximum length 256
  538. which specifies the window's title.
  539. .IP WOG_SIZE
  540. This consists of two 12-bit integers
  541. which respectively specify the vertical and horizontal
  542. size of the window on the client's screen
  543. (in pixels).
  544. .IP WOTTY_SIZE
  545. This consists of two 12-bit integers
  546. which respectively specify the window size in rows and columns.
  547. .IP WOTTY_FONTSZ
  548. This is a 6-bit integer which is a font size index.
  549. At present,
  550. it specifies a ``small'' font if zero
  551. and a ``large'' font if nonzero.
  552. .IP WOTTY_MOUSE
  553. This is a 1-bit integer
  554. which is nonzero iff
  555. mouse events are to be encoded and sent
  556. as data to the host.
  557. .IP WOTTY_BELL
  558. This is a 2-bit integer.
  559. The low-order bit is set iff the window should
  560. display bells visually;
  561. the other bit is set iff the client should report
  562. bells within this window audibly.
  563. .IP WOTTY_CURSOR
  564. This is a 1-bit integer
  565. which is zero if the window is using a block cursor
  566. and nonzero if the window is using an underscore cursor.
  567. .PP
  568. One design decision which the author now regrets
  569. is an overloading of the WOTTY_SIZE option.
  570. If the host can handle window size changes on pseudo-terminals
  571. (\fIe.g.\fP 4.3BSD can),
  572. then the client is capable of changing the view size of a window
  573. or its actual size,
  574. according to the user's preference.
  575. If the host cannot handle window size changes,
  576. the client does not allow the view size to be changed.
  577. The client assumes that the host can handle window size
  578. changes if it receives a WOC_DO command for the WOTTY_SIZE option.
  579. .SH
  580. Protocol Negotiation
  581. .PP
  582. It is possible that at some time the versions of a \*(uw server
  583. and client will not match;
  584. .I e.g.
  585. a version 2.10 client will be used with a version 3.4 server.
  586. It is desirable that such combinations will work ``correctly'' \(em
  587. that the server will communicate with the client using protocol 1
  588. rather than trying to use protocol 2.
  589. In order to accomplish this,
  590. three new maintenance functions
  591. are defined by which the server and client
  592. may negotiate the protocol which is to be used.
  593. Version 3 clients and servers recognize these maintenance
  594. functions in both protocol 1 and protocol 2.
  595. Older clients and servers do not recognize these functions
  596. at all.
  597. .PP
  598. The protocol negotiation maintenance functions were
  599. described above for protocol 2.
  600. They are repeated here for protocol 1
  601. (the encodings are identical):
  602. .DS
  603. .T=
  604. #define    P1_MF_ASKPCL    2    /*    request protocol negotiation */
  605. #define    P1_MF_CANPCL    3    /*    suggest protocol */
  606. #define    P1_MF_SETPCL    4    /*    set new protocol */
  607. .DE
  608. P1_MF_ASKPCL is encoded in a single command byte
  609. (following P1_IAC).
  610. The P1_MF_CANPCL and P1_MF_SETPCL command bytes are
  611. followed by an additional byte which names a protocol.
  612. For the purposes of protocol negotiation,
  613. protocols 1 and 2 are represented by the ASCII
  614. characters space and exclamation-mark,
  615. respectively.
  616. .PP
  617. The client and server always start operation in protocol 1.
  618. (The user may have instructed the client to use protocol 2;
  619. nonetheless,
  620. it will use protocol 1 until protocol negotiations are complete.)
  621. When the server is started
  622. it will send a P1_MF_ENTRY maintenance command to the client.
  623. If the client knows about protocol 2 and wishes to use it,
  624. it will send a P1_MF_ASKPCL to the server.
  625. If the client does not know about protocol 2,
  626. it will not send P1_MF_ASKPCL,
  627. protocol negotiation will never be started,
  628. and both sides will continue to use protocol 1.
  629. .PP
  630. If the server can support something other than protocol 1
  631. it will respond to the P1_MF_ASKPCL with a
  632. P1_MF_CANPCL which names the most extensive protocol that it can support.
  633. (At present,
  634. this will be protocol 2;
  635. however,
  636. in the future it might name some other protocol.)
  637. Old servers,
  638. which do not recognize P1_MF_ASKPCL,
  639. will ignore the maintenance function.
  640. The client will time out after five seconds
  641. and retry several times
  642. (three in the present implementation);
  643. if the server never responds
  644. the client will ``give up'' and will
  645. continue to use protocol 1 indefinitely.
  646. .PP
  647. When the client receives P1_MF_CANPCL from the server,
  648. it will examine the server's suggested protocol.
  649. If this protocol is unacceptable to the client,
  650. it will respond with its own P1_MF_CANPCL,
  651. naming the most extensive protocol that it can support.
  652. The server,
  653. upon receipt of this P1_MF_CANPCL,
  654. will examine the client's suggested protocol.
  655. If it is unacceptable to the server,
  656. it will name the second-most extensive protocol that it can support.
  657. Each time that the client or server receives a
  658. P1_MF_CANPCL that names a protocol it cannot support,
  659. it will respond with a different,
  660. less extensive suggestion of its own.
  661. Since the number of protocols is finite,
  662. eventually someone will suggest protocol 1,
  663. which both sides are required to support.
  664. .PP
  665. When the client or server receives a P1_MF_CANPCL
  666. that names a protocol that it
  667. .I can
  668. support,
  669. it will instruct its counterpart to start using that protocol
  670. by sending a P1_MF_SETPCL that names that protocol.
  671. Henceforth,
  672. the new protocol will be used.
  673. .PP
  674. Protocol 2 allows the client to send a P2_MF_ENTRY
  675. maintenance command to the server.
  676. (This is encoded identically to a P1_MF_ENTRY command.)
  677. If the server receives this maintenance command and
  678. it is using a protocol other than protocol 1,
  679. it will immediately respond with a P1_FN_SETPCL which
  680. names the protocol that it is using.
  681. It will then proceed to send ``new window'' and
  682. (if applicable)
  683. ``window option'' commands to the client
  684. to reconstruct the client's current state.
  685. .SH
  686. Postscript
  687. .PP
  688. There are a number of obvious problems with the mechanism
  689. for protocol negotiation.
  690. It is possible for one party to send a SETPCL
  691. command and begin listening for input in a new protocol
  692. while it is still receiving buffered commands in the old protocol
  693. from the other party.
  694. It probably would have been better to have established
  695. a ``current protocol'',
  696. similar to the ``current window'' scheme used for data transfer.
  697. This scheme was born out of the desire to allow
  698. old servers and clients to work with new ones.
  699. It ``works'' if things are relatively quiescent,
  700. as they are when the server first starts up
  701. (before it creates its first window).
  702. .PP
  703. This document is still incomplete.
  704. At this time it is more useful as a conceptual guide
  705. to the \*(uw protocol
  706. than a definitive reference.
  707. .SH
  708. Copyright
  709. .LP
  710. This document copyright 1986 by John D. Bruner.
  711. Permission to copy is given,
  712. provided that the copies are not sold
  713. and that this copyright notice is included.
  714.